<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
          <div class="layui-form-item">
              <label class="layui-form-label">用户id</label>
              <div class="layui-input-block">
                  <input type="text" id="userId" name="userId"   autocomplete="off" placeholder="请输入用户id"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">订单ordernum外键</label>
              <div class="layui-input-block">
                  <input type="text" id="ordernum" name="ordernum"   autocomplete="off" placeholder="请输入订单ordernum外键"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">司机姓名 </label>
              <div class="layui-input-block">
                  <input type="text" id="driverName" name="driverName"   autocomplete="off" placeholder="请输入司机姓名 "
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">司机电话</label>
              <div class="layui-input-block">
                  <input type="text" id="driverPhone" name="driverPhone"   autocomplete="off" placeholder="请输入司机电话"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">公交车牌号</label>
              <div class="layui-input-block">
                  <input type="text" id="busNum" name="busNum"   autocomplete="off" placeholder="请输入公交车牌号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">0 全款 派车单   1定金派车单</label>
              <div class="layui-input-block">
                  <input type="text" id="payType" name="payType"   autocomplete="off" placeholder="请输入0 全款 派车单   1定金派车单"
                         class="layui-input">
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         userId:$("#userId").val(),
                         ordernum:$("#ordernum").val(),
                         driverName:$("#driverName").val(),
                         driverPhone:$("#driverPhone").val(),
                         busNum:$("#busNum").val(),
                           payType:$("#payType").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/bus/paiChe/addPaiChe",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/bus/paiChe/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#userId").val().length<1){
                       layer.msg("请输入用户id");
                       return false;
                   }
                   if($("#ordernum").val().length<1){
                       layer.msg("请输入订单ordernum外键");
                       return false;
                   }
                   if($("#driverName").val().length<1){
                       layer.msg("请输入司机姓名 ");
                       return false;
                   }
                   if($("#driverPhone").val().length<1){
                       layer.msg("请输入司机电话");
                       return false;
                   }
                   if($("#busNum").val().length<1){
                       layer.msg("请输入公交车牌号");
                       return false;
                   }
                   if($("#payType").val().length<1){
                       layer.msg("请输入0 全款 派车单   1定金派车单");
                       return false;
                   }
        }
    });

</script>
</body>
</html>